package com.atguigu.srb.core.controller.admin;

import com.atguigu.srb.common.result.Result;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.atguigu.srb.core.service.BorrowInfoService;
import com.atguigu.srb.core.service.LendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author lsyandwh
 * @create 2022-12-16 15:01
 */
@Api(tags = "借款申请管理")
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowerInfoController {

    @Autowired
    private BorrowInfoService borrowInfoService;

    @Autowired
    private LendService lendService;

    @ApiOperation("借款申请列表")
    @GetMapping("/list")
    public Result list(){

        List<BorrowInfo> list = borrowInfoService.getList();

        return Result.ok().data("list",list);
    }

    @ApiOperation("借款申请详细信息")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id){
        Map<String, Object> map = borrowInfoService.gteBorrowInfoDetail(id);

        return Result.ok().data("borrowInfoDetail",map);
    }

    @ApiOperation("借款审批")
    @PostMapping("/approval")
    public Result approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){

        borrowInfoService.approval(borrowInfoApprovalVO);

        return Result.ok().message("审核完成");
    }
}
